package com.wnxy.sddfp.access.cofig;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    /**
     * 队列: sddfp-queue-bind
     * 交换机: sddfp-exchange-bind
     * 路由key: bind-card-message
     */
    String SDDFP_QUEUE_BIND = "sddfp-queue-bind";
    String SDDFP_EXCHANGE_BIND = "sddfp-exchange-bind";
    String BIND_CARD_MESSAGE = "bind-card-message";

    /**
     * 队列:    sddfp-queue-bind
     * 交换机:  sddfp-exchange-bind
     * 路由key: bind-card-message
     */
    @Bean
    public Queue queueBind() {
        return QueueBuilder.durable(SDDFP_QUEUE_BIND).build();
    }

    @Bean
    public DirectExchange exchangeBind() {
        return new DirectExchange(SDDFP_EXCHANGE_BIND);
    }

    @Bean
    public Binding binding(Queue queueBind, DirectExchange exchangeBind) {
        return BindingBuilder.bind(queueBind).to(exchangeBind).with(BIND_CARD_MESSAGE);
    }
}